package cn.getech.data.metadata.model.req.meta;

import cn.getech.data.intelligence.common.validator.group.AddGroup;
import cn.getech.data.intelligence.common.validator.group.UpdateGroup;
import cn.getech.data.metadata.entity.meta.CollectionTask;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
public class CollectionTaskSave {

    private Long id;

    @ApiModelProperty("任务名称")
    @NotBlank(message = "任务名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String taskName;


    @ApiModelProperty("0 手动采集 1自动采集")
    @NotNull(message = "任务类型不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private Integer taskType;


    @ApiModelProperty("所属系统id")
    private Integer ownSystem;


    @ApiModelProperty("所属模块id")
//    @NotNull(message = "所属模块id不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private Integer ownModule;

    @ApiModelProperty("更新人")
    private Long updateUser;

    private String updateUserName;

    private JobNodeConfig taskConfig;

    @ApiModelProperty("导入方式 0 增量 1 全量")
    private Integer exportType;

    @ApiModelProperty("初始化角色")
    private Long initRole;

    @ApiModelProperty("通知用户组id")
    private List<Long>  userGroupNameId;


    public CollectionTaskSave() {
    }
    public CollectionTask toCollectionTask() {
        CollectionTask record = new CollectionTask();
        record.setId(this.id);
        record.setTaskName(this.taskName);
        record.setTaskType(this.taskType);
        record.setOwnModule(this.ownModule);
        if(this.ownSystem==null){
            record.setOwnSystem(-1);
        }
        record.setExportType(this.exportType);
        record.setInitRole(this.initRole);
        record.setCategoryIdsList(this.categoryIdsList);
        if (taskConfig != null) {
            record.setTaskConfig(JSONObject.toJSONString(taskConfig));
        }
        return record;
    }


    /**
     * 目录id
     */
    private List<String> categoryIdsList;

}
